
export interface Animal{
    readonly name: string // readonly相当于kotlin中的val，初始化后不能再被赋值
    eat(food: string): void
    sleep(hours: number): void
}


export class Cat implements Animal{
    readonly name: string = "Cat"
    eat(food: string): void {
        console.info(`${this.name} - eat:${food}`);
    }

    sleep(hours: number): void {
        console.info(`${this.name} - sleep:${hours}`);
    }
}

export class Dog  implements Animal{
    readonly name: string = "Dog"

    eat(food: string): void {
        console.info(`${this.name} - eat:${food}`);
    }

    sleep(hours: number): void {
        console.info(`${this.name} - sleep:${hours}`);
    }
}
